﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronCow.UnitTests.Mock
{
    class MockRtm : Rtm
    {
        public MockRtm()
            : base(new MockRestClient())
        {
        }

        public MockRtm(string method, MockResponse response)
            : this()
        {
            AddResponse(method, response);
        }

        public void AddResponse(string method, MockResponse response)
        {
            ((MockRestClient)Client).AddResponse(method, response);
        }

        public void AddSuccessResponse(string method, params MockResponsePart[] parts)
        {
            MockSuccessResponse response = new MockSuccessResponse();
            foreach (var part in parts)
            {
                response.Add(part);
            }
            ((MockRestClient)Client).AddResponse(method, response);
        }

        public void AddErrorResponse(string method, int errorCode)
        {
            ((MockRestClient)Client).AddResponse(method, new MockErrorResponse(errorCode));
        }

        public void AddTimelineResponse()
        {
            AddResponse("rtm.timelines.create",
                new MockSuccessResponse() { new MockTimelineResponsePart() });
        }

        public void EnsureAllResponsesUsed()
        {
            ((MockRestClient)Client).EnsureAllResponsesUsed();
        }
    }
}
